@extends('admin._layouts.default')

<script language="javascript" type="text/javascript" src="{{ URL::asset('ueditor/ueditor.config.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('ueditor/ueditor.config.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('ueditor/ueditor.all.min.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('ueditor/lang/zh-cn/zh-cn.js') }}"></script>
    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
@section('main')


      <div class="row-fluid ">
        <div class="box gradient">
          <div class="title">
            <h3><a href="order_box_add.html"  class="btn btn-mini pull-right" style="margin:5px 5px 0 0"><i class="fa fa-hand-o-left"></i> 返回</a>
            <i class="fa fa-share-alt"></i><span>发布分享文章</span>
            </h3>
          </div>
          <div class="content">

            {{ Form::model($page, array('method' => 'put', 'route' => array('admin.pages.update', $page->id),'files'=>true,'id'=>'pages')) }}
                  <div class="form-row control-group row-fluid">
                    <label class="control-label span3" for="text">文章标题</label>
                    <div class="controls span5">
                      <div class="input-prepend row-fluid">
                        <span class="add-on prepend "><i class="fa fa-wechat "></i></span>
                        <input name="title" value="{{ $page->title }}" class="row-fluid" id="cloth2" required  size="50" type="text" placeholder="分享文章标题">
                      </div>
                    </div>
                  </div>
                  <div class="form-row control-group row-fluid">
                    <label class="control-label span3" for="text">奖励积分</label>
                    <div class="controls span3">
                      <div class="input-prepend input-append row-fluid">
                        <span class="add-on prepend "><i class="fa fa-credit-card"></i></span>
                        <input name="point" value="{{ $page->point }}" class="row-fluid" id="price2" required  size="6" type="text"  placeholder="奖励积分">
                        <span class="add-on ">/点击</span>
                      </div>
                    </div>
                  </div>
                  <div class="form-row control-group row-fluid">
                    <label class="control-label span3" for="search-input">头图上传</label>
                    <div class="controls span7">
                      <div class="input-append row-fluid">
                        <input name="cover" type="file" class="spa1n6 fileinput" id="search-input">
                      </div>
                    </div>
                  </div>

                  <div class="form-row control-group row-fluid">
                    <label class="control-label span3" for="text">文章摘要</label>
                    <div class="controls span5">
                      <textarea name="dec"  onkeyup="javascript:checkWord(this);" onmousedown="javascript:checkWord(this);" id="text" rows="3" class="row-fluid">{{ $page->dec }}
                      </textarea>
                      <div id="bottom">
                        <span id="wordCheck">100</span> 字剩余
                      </div>
                    </div>
                  </div>
                  <div class="form-row control-group row-fluid">
                    <label class="control-label span3" for="editor1">文章内容
                    </label>
                    <div class="controls span5">
                        <script id="editor" type="text/plain" style="height:500px;">{{ $page->body }}</script>
                    </div>
                  </div>
                  <div class="form-actions row-fluid">
                    <div class="span10 offset3">
                      <button type="submit" onclick="fabu()" class="btn btn-large btn-info"><i class="fa fa-paper-plane"></i> 立即发布</button>
                    </div>
                  </div>
                  {{ Form::close() }}


@stop
@section('script')
<script language="javascript" type="text/javascript" src="{{ URL::asset('web/js/plugins/jquery.peity.min.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('web/js/plugins/jquery.uniform.min.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('web/js/plugins/chosen/chosen/chosen.jquery.min.js') }}"></script>

<script language="javascript" type="text/javascript" src="{{ URL::asset('web/js/plugins/flot/jquery.flot.js') }}"></script>



<script src="{{ URL::asset('web/js/scripts.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('web/js/jnavigate.jquery.min.js') }}"></script>

<script type="text/javascript">

    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    var ue = UE.getEditor('editor');

</script>
<script type="text/javascript">

        var maxstrlen = 100;
        function Q(s) { return document.getElementById(s); }

        function checkWord(c) {
            len = maxstrlen;
            var str = c.value;
            myLen = getStrleng(str);
            var wck = Q("wordCheck");

            if (myLen > len * 2) {
                c.value = str.substring(0, i + 1);
            }
            else {
                wck.innerHTML = Math.floor((len * 2 - myLen) / 2);
            }
        }

        function getStrleng(str) {
            myLen = 0;
            i = 0;
            for (; (i < str.length) && (myLen <= maxstrlen * 2); i++) {
                if (str.charCodeAt(i) > 0 && str.charCodeAt(i) < 128)
                    myLen++;
                else
                    myLen += 2;
            }
            return myLen;
        }
        function fabu(){
            $('#pages').submit();
        }
</script>
@stop